import request from '../utils/request';  // request 是 demo 项目脚手架中提供的一个做 http 请求的方法，是对于 fetch 的封装，返回 Promise
import {deleteImages} from '../services/deleteimage'
const delay = (millisecond) => {
  return new Promise((resolve) => {
    setTimeout(resolve, millisecond);
  });
};

export default {
  namespace: 'deleteimage',
  state: {
    data: [],
    counter: 0,
      },
  effects: {
    *deleteImage({payload}, sagaEffects) {
      const { call, put } = sagaEffects;
      const endPointURI = '/dev/random_joke';

	 // 
      console.log("the",payload);
      const puzzle = yield call(deleteImages,payload);
    //console.log(puzzle.info.data);
    //yield put({ type: 'addNewCard', payload: puzzle.info.data });

  
    }
  },
  reducers: {
    addNewCard(state, { payload: newCard }) {
      //console.log("the new card is ",newCard);
      const nextCounter = state.counter + 1;
      //const newCardWithId = { ...newCard, id: nextCounter };
      //console.log("the newCardWithId",newCardWithId);
      const nextData = state.data.concat(newCard);//list
      console.log("the nextdata is",nextData);
      return {
        data: newCard,
        counter: nextCounter,
      };
    }
  },
};